package com.example.app.components


import androidx.compose.animation.*
import androidx.compose.foundation.layout.Column
import androidx.compose.material.Button
import androidx.compose.material.Text
import androidx.compose.runtime.*
import androidx.compose.ui.tooling.preview.Preview

@OptIn(ExperimentalAnimationApi::class)
@Composable
fun AnimationContent() {
    var num by remember {
        mutableStateOf(0)
    }
    Column {
        Button(onClick = {
            num++
        }) {
            Text(text = "+")
        }
        Button(onClick = {
            num--
        }) {
            Text(text = "-")
        }
        // 自定义动画效果
        // targetState 目标值
        // initialState 初始值
//        AnimatedContent(targetState = num, transitionSpec = {
//            if (targetState > initialState) {
//                (slideInVertically({
//                        fullHeight ->
//                    fullHeight
//                }) + fadeIn() with slideOutVertically({
//                        fullHeight ->
//                    -fullHeight
//                }) + fadeOut())
//            } else {
//                (slideInVertically({
//                        fullHeight ->
//                    -fullHeight
//                }) + fadeIn() with slideOutVertically({
//                        fullHeight ->
//                    -fullHeight
//                }) + fadeOut())
//            }
//        }) {
//            num ->
//            Text(text = "$num")
//        }
        Text(text = "num: $num")
    }
}

@Preview(
    showSystemUi = true
)
@Composable
fun AnimationContentPreview() {
    AnimationContent()
}

